package abacab.serialization.huffman;

import java.util.Comparator;

/**
 * Represents a node in the binary tree
 */
public abstract class Node {

	/** The node's comparator */
	public static final Comparator<Node>	COMPARATOR	= new Comparator<Node>() {
																											@Override
																											public int compare(Node o1, Node o2) {
																												return o1.getWeight() <= o2.getWeight() ? -1 : 1;
																											}
																										};

	/** The node's weight */
	private int														weight;

	/**
	 * Create the node
	 * 
	 * @param weight
	 *          the node's weight
	 */
	protected Node(int weight) {
		this.weight = weight;
	}

	/**
	 * Add weight to the node
	 */
	public void addWeight() {
		this.weight++;
	}

	/**
	 * @return the weight
	 */
	public final int getWeight() {
		return this.weight;
	}

	/**
	 * @return the character
	 */
	public abstract char getCharacter();

	/**
	 * @return the node to the left
	 */
	public abstract Node getLeft();

	/**
	 * @return the node to the right
	 */
	public abstract Node getRight();
}